#include <stdio.h>
#include <math.h>

int ChangeHex(char num) {
    char j = 0;
    int output = 0;
    char binOrigin[] = {0, 0, 0, 0, 0, 0, 0, 0};
    char binChanged[] = {0, 0, 0, 0, 0, 0, 0, 0};
    for (int i = 0; i < 8; i++){
        binOrigin[7-i] = num % 2;
        num = num / 2;
    }
    binChanged[0] = binOrigin[3];
    binChanged[1] = binOrigin[4];
    binChanged[2] = binOrigin[5];
    binChanged[3] = binOrigin[6];
    binChanged[4] = binOrigin[7];
    binChanged[5] = binOrigin[0];
    binChanged[6] = binOrigin[2];
    binChanged[7] = binOrigin[1];
    for (int i = 0; i < 8; i++){
        output = output + binChanged[7 - i] * pow(2,i);
    }
    return output;
}
void main(){
    char org[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71, 0x00};
    int i = 0;
    int num = 0;
    printf("\n{");
    while((num = org[i]) != 0x00){
        printf("0x%x, ", ChangeHex(num));
        i++;
    }
    printf("}\n");
    printf("\n0:%x", ChangeHex(org[0]));
}